package com.hzw.saas.common.quartz.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hzw.saas.common.config.util.PageParam;
import com.hzw.saas.common.quartz.model.ScheduleJobLog;
import com.hzw.saas.common.quartz.service.IScheduleJobLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "定时任务执行日志")
@RequestMapping("/sys/scheduleLog")
@RequiredArgsConstructor
public class ScheduleJobLogController {
	private final IScheduleJobLogService scheduleJobLogService;

	@GetMapping("/page")
    @ApiOperation(value = "定时任务日志列表")
	public ResponseEntity<IPage<ScheduleJobLog>> page(Long jobId, PageParam pageParam){
		IPage<ScheduleJobLog> page = scheduleJobLogService.page(pageParam.convert(),
            new LambdaQueryWrapper<ScheduleJobLog>()
                .eq(jobId != null,ScheduleJobLog::getJobId,jobId));
		return ResponseEntity.ok(page);
	}
}
